// Logic 248: Global actions

#include "defines.txt"
#define score_music_completed f255

if (input_received && unknown_word_no == 0 && !input_parsed) {

  if (said("look", "rock")) {
    print("There are boulders of several sizes strewn about the landscape.");
  }

  if (said("get", "rock")) {
    print("All the rocks here are too heavy for you to pick up and carry.");
  }

  if (said("move", "rock")) {
    print("You're unable to move any of the rocks here.");
  }

  if (said("look", "sky")) {
    print("There are some clouds visible in an otherwise bright sky.");
  }

  if (said("look", "clouds")) {
    print("You don't know much about clouds. You can only tell that the clouds look pretty.");
  }

  if (said("look", "horizon")) {
    print("The horizon stretches into, well, the horizon. There are no islands in the distance to be seen.");
  }

  if (said("look", "ground")) {
    if ((room_no == stream || room_no == waterfall)) {
      print("The ground is covered in grass.");
    } else {
      print("For the most part, the ground is covered in sand.");
    }
  }

  if (said("look", "sea")) {
    if ((room_no == beach || room_no == boulders)) {
      print("The beautiful blue sea continues as far as the eye can see.");
    } else {
      print("You see the sea in the distance.");
    }
  }

  if (said("look", "water")) {
    if ((room_no == beach || room_no == boulders)) {
      print("The water in the sea appears to be clean.");
    } else {
      print("The water in the stream flows towards the sea.");
    }
  }

  if (said("look", "waves")) {
    if ((room_no == waterfall)) {
      print("The waterfall creates small waves in the pond at its base. In the distance, you see waves splashing on the beach.");
    } else {
      print("The waves splash gently on the beach.");
    }
  }

  if (said("look", "flowers")) {
    print("You see no flowers here.");
  }

  if (said("look", "sand")) {
    if ((room_no == beach || room_no == boulders)) {
      print("It's just ordinary sand that you would find at any ordinary beach.");
    } else {
      print("You see a sandy beach in the distance.");
    }
  }

  if (said("get", "sand")) {
    print("You have no need for sand.");
  }

  if ((room_no == beach || room_no == boulders)) {
    if ((said("dig", "sand") || said("dig", "ground"))) {
      print("You could dig the sand, but that would serve no purpose.");
    }
  }

  if (said("swim")) {
    if ((room_no == beach || room_no == boulders)) {
      print("You're not very good at swimming. Let's not.");
    } else {
      print("The water in the stream is way too shallow for swimming.");
    }
  }

  if (said("dive")) {
    if ((room_no == beach || room_no == boulders)) {
      print("There isn't anything interesting underwater.");
    } else {
      print("The water in the stream is way too shallow for diving.");
    }
  }

  if (said("climb", "rock")) {
    print("There's no reason to scale any of the rocks here.");
  }

  if (said("climb", "tree")) {
    print("You would be unable to gain a foothold to climb the trees.");
  }

  if ((room_no == stream || room_no == waterfall)) {
    if (said("look", "grass")) {
      print("The ground is covered in beautiful green grass.");
    }
    if (said("look", "foliage")) {
      print("The nature here is beautiful. This must be a very fertile area.");
    }
    if (said("look", "bush")) {
      print("Several large bushes of different colors are growing in this area.");
    }
    if (said("search", "bush")) {
      print("There is nothing of interest in the bushes.");
    }
    if (said("look", "roots")) {
      print("Be careful not to trip over the roots of trees here.");
    }
    if (said("look", "leaves")) {
      print("The leaves flutter in the wind.");
    }
    if (said("dig", "sand")) {
      print("You need to go to the beach to dig the sand.");
    }
    if (said("dig", "rol")) {
      print("You're unable to do any digging here.");
    }
  }

  if (has(sealed_bottle)) {
    if (said("look", "red object")) {
      print("It's impossible to see the red object clearly due to optical distortion caused by the bottle. It appears that you need to get the object out of the bottle somehow before you can inspect it further.");
    }
    if ((said("get", "red object", "rol") || said("remove", "red object", "rol"))) {
      print("You need to open the bottle to do that.");
    }
    if ((said("open", "bottle") ||
         said("remove", "cork") ||
         said("open", "cork") ||
         said("open", "cork", "bottle") ||
         said("open", "bottle", "cork") ||
         said("remove", "cork", "bottle") ||
         said("pull", "cork") ||
         said("pull", "cork", "bottle"))) {
      print("The cork on the bottle has been pushed in way too tight. You're unable to remove it with your bare hands.");
    }
    if (said("look", "cork")) {
      print("It's just an ordinary cork.");
    }
    if (said("suck", "cork", "rol")) {
      print("Good thinking!");
      print("Unfortunately, not good enough. Despite your best efforts, the cork remains firmly in the bottle.");
    }
    if ((said("put", "bottle", "water") || said("drop", "bottle", "water"))) {
      print("That would serve no purpose.");
    }
    if (said("shake", "bottle")) {
      print("You shake the bottle. The object inside rattles, but the cork remains tightly in place.");
    }
  }

  if (has(empty_bottle)) {
    if ((said("fill", "bottle", "water") || said("get", "water", "bottle"))) {
      print("You have no need for water.");
    }
  }

  if ((said("break", "bottle") || said("break", "bottle", "rol"))) {
    if ((has(sealed_bottle) || has(empty_bottle))) {
      print("You don't want to break the bottle. The broken glass could be hazardous to animals. Besides, you might hurt yourself.");
    } else {
      reset(input_parsed);
    }
  }

  if ((said("open", "bottle", "hook") ||
       said("open", "cork", "hook") ||
       said("open", "cork", "bottle", "hook") ||
       said("open", "bottle", "cork", "hook") ||
       said("use", "hook", "bottle") ||
       said("use", "hook", "open", "bottle") ||
       said("use", "hook", "remove", "cork") ||
       said("use", "hook", "cork") ||
       said("remove", "cork", "hook") ||
       said("remove", "cork", "bottle", "hook", "rol") ||
       said("pull", "cork", "hook", "rol") ||
       said("pull", "cork", "bottle", "hook", "rol"))) {
    if (has(sealed_bottle)) {
      if (has(hook)) {
        print("Using the hook, you pull the cork out of the mouth of the bottle. The cork breaks into pieces in the process.");
        print("The red object inside the bottle turns out to be a stick of dynamite!");
        print("You remove the stick of dynamite from the bottle.");
        drop(sealed_bottle);
        get(empty_bottle);
        get(dynamite);
        score += 1;
        sound(score_music, score_music_completed);
      } else {
        print("You don't have a hook.");
      }
    } else {
      if (has(empty_bottle)) {
        print("You already did that, remember?");
      } else {
          if (has(hook)) {
            print("You don't have a bottle.");
          } else {
            print("What on Earth are you talking about? You lack both a bottle and a hook!");
          }
      }
    }
  }

  if ((said("put", "bottle", "water") || said("drop", "bottle", "water"))) {
    if (has(empty_bottle)) {
      print("That's a clever idea in principle, but it wouldn't help you in your quest.");
    } else {
      reset(input_parsed);
    }
  }

  if (said("drink", "water")) {
    if ((room_no == stream || room_no == waterfall)) {
      print("You don't feel thirsty.");
    } else {
      print("The seawater is too salty to drink. Besides, you don't feel thirsty.");
    }
  }

  if (said("eat", "dynamite")) {
    print("That wouldn't be very smart!");
  }

  if (said("look", "bottle")) {
    if ((has(sealed_bottle) || has(empty_bottle))) {
      if (has(sealed_bottle)) {
        show.obj(101);
      } else {
        show.obj(102);
      }
    } else {
      print("You don't have it.");
    }
  }

  if (said("look", "hook")) {
    if (has(hook)) {
      show.obj(103);
    } else {
      print("You don't have it.");
    }
  }

  if (said("look", "dynamite")) {
    if (has(dynamite)) {
      show.obj(104);
    } else {
      print("You don't have it.");
    }
  }

  if ((said("ignite", "dynamite") || said("ignite", "fuse"))) {
    if (has(dynamite)) {
      print("You need to be more specific. How do you plan on doing that?");
    } else {
      print("You don't have any dynamite.");
    }
  }

  if ((said("light", "dynamite", "magnifying glass") ||
       said("light", "fuse", "magnifying glass") ||
       said("light", "dynamite", "fuse", "magnifying glass") ||
       said("light", "fuse", "dynamite", "magnifying glass") ||
       said("use", "magnifying glass", "fuse") ||
       said("use", "magnifying glass", "dynamite") ||
       said("use", "magnifying glass", "dynamite", "fuse") ||
       said("use", "magnifying glass", "fuse", "dynamite") ||
       said("use", "magnifying glass", "light", "dynamite") ||
       said("use", "magnifying glass", "light", "fuse") ||
       said("use", "magnifying glass", "light", "dynamite", "fuse") ||
       said("use", "magnifying glass", "light", "fuse", "dynamite"))) {
    if (has(dynamite)) {
      print("Good thinking. But first, find a good place to use the dynamite.");
    } else {
      print("You don't have any dynamite.");
    }
  }

  if (said("look", "magnifying glass")) {
    if (has(magnifying_glass)) {
      show.obj(105);
    } else {
      print("You don't have it.");
    }
  }

  if (said("look", "rope")) {
    if (has(rope)) {
      show.obj(106);
      print("(With apologies to Gertrude Stein and Al Lowe.)");
    } else {
      print("You don't have it.");
    }
  }

  if ((said("tie", "rope", "rol") || said("attach", "rope", "rol"))) {
    print("That's not going to help you.");
  }

  if ((said("strip") || said("remove", "clothes") || said("take clothes off"))) {
    print("Yeah, right. Like we're really going to show that.");
  }

  if (said("talk", "rol")) {
    print("There is nobody here to talk to.");
  }

  if (said("walk", "rol")) {
    print("Just walk wherever you want to walk.");
  }

  if (said("sit", "rol")) {
    print("You don't feel like sitting, as you're very anxious to finish your quest.");
  }

  if (said("sleep", "rol")) {
    print("This is not the time nor the place to sleep.");
  }

  if (said("run", "rol")) {
    print("You can run, but you can't hide.");
    print("Well, you can't run, either. At least not in this game.");
  }

  if (said("listen", "rol")) {
    print("All you hear are the sounds of nature: the chirping of birds, the splashing of waves and the hum of leaves fluttering in the wind.");
  }

  if (said("smell", "rol")) {
    print("You don't smell anything special.");
  }

  if (said("taste", "rol")) {
    print("The only thing you can taste is your taste for adventure.");
  }

  if (said("xyzzy", "rol")) {
    print("Nothing happens.");
  }

  if (said("wait", "rol")) {
    print("Time passes.");
    print("No, wait.");
    print("This isn't a text adventure!");
  }

  if (said("george carlin", "rol")) {
    print("Who do you think you are? George Carlin?");
  }

  if (said("drop", "rol")) {
    print("There is no need for you to drop anything right now.");
  }

  if (said("throw", "rol")) {
    print("You don't need to throw anything right now.");
  }

  if (said("look", "behind", "rol")) {
    print("You see nothing unusual, Sherlock.");
  }

  if ((said("look", "anyword") ||
       said("look", "anyword", "anyword") ||
       said("look", "anyword", "anyword", "anyword"))) {
    print("You see nothing special.");
  }

  if ((said("get", "anyword") ||
       said("get", "anyword", "anyword") ||
       said("get", "anyword", "anyword", "anyword"))) {
    print("You can't do that.");
  }

  if ((said("use", "anyword") ||
       said("use", "anyword", "anyword") ||
       said("use", "anyword", "anyword", "anyword"))) {
    print("Please be more specific.");
  }

}

if (input_received && unknown_word_no > 0) {
  reset(input_received);
  if (unknown_word_no == 1) {
    print("I don't understand \"%w1\".");
    if (debug_active) {
      log("Unknown word: %w1");
    }
  }
  if (unknown_word_no == 2) {
    print("I don't understand \"%w2\".");
    if (debug_active) {
      log("Unknown word: %w2");
    }
  }
  if (unknown_word_no == 3) {
    print("I don't understand \"%w3\".");
    if (debug_active) {
      log("Unknown word: %w3");
    }
  }
  if (unknown_word_no == 4) {
    print("I don't understand \"%w4\".");
    if (debug_active) {
      log("Unknown word: %w4");
    }
  }
  if (unknown_word_no == 5) {
    print("I don't understand \"%w5\".");
    if (debug_active) {
      log("Unknown word: %w5");
    }
  }
  if (unknown_word_no == 6) {
    print("I don't understand \"%w6\".");
    if (debug_active) {
      log("Unknown word: %w6");
    }
  }
}

if (input_received && !input_parsed) {
  print("I don't understand your request. Please try to rephrase it.");
  reset(input_received);
  if (debug_active) {
    log("Input not understood");
  }
}

return();